Enhance payment processing with additional logging and error handling in CreateTransactionView and ConfirmTransactionView #399
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
finance: add structured debug logging and harden Mollie payment flow
Instrument CreateTransactionView, ConfirmTransactionView, and PaymentWebHook with structured logs:
Short, consistent event messages; detailed context in extra (order_id, user_id, mollie_id, status, checkout_url, remote IP, is_paid)
Logs cover initiation, redirect, confirm/return, webhook, and error paths
Wrap Mollie API calls in try/except and log failures with context
On initiation failure: unfreeze order (finalized=False), show user-friendly error, and redirect to retry
Ensure mollie_id extraction works with dict-like and attribute results (supports tests’ FakePaymentResult)
Return 404 for webhook calls missing id (aligns with existing tests)
Keep EventLog.event <= 255 chars; move long details (URLs, exceptions) to extra
Preserve success-path behavior; no functional changes to payment completion logic
Testing:
Ran test suite; finance-related tests pass after adjustments
One unrelated ordering time-bound test fails (quarter-end edge), not impacted by these changes
Notes:
Expect increased EventLog volume; consider adding admin filters or retention as needed
These logs should make it clear where “paid but not completed” flows stall (initiation vs return vs webhook) and with which Mollie status/ids